# -*- coding: utf-8 -*-

"""
Description:
"""
import requests


def search_product(keyword: str) -> str:
    """搜索商品

    Args:
        keyword (str): 搜索关键词

    Returns:
        str: 搜索结果HTML内容
    """
    url = "https://www.liankebio.com/"

    headers = {
        "Referer": "https://www.liankebio.com/",
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36",
    }

    params = {"post_type": "product", "s": keyword}

    response = requests.get(url, headers=headers, params=params)

    if response.status_code == 200:
        return response.text
    else:
        raise Exception(f"搜索商品失败,状态码:{response.status_code}")
    
def get_product_detail(url: str) -> str:
    """搜索商品

    Args:
        keyword (str): 搜索关键词

    Returns:
        str: 搜索结果HTML内容
    """

    headers = {
        "Referer": "https://www.liankebio.com/",
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36",
    }

    response = requests.get(url, headers=headers)

    if response.status_code == 200:
        return response.text
    else:
        raise Exception(f"搜索商品失败,状态码:{response.status_code}")
    
